Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Endless loop when table value dependent on 'select' event #2069 #2082

Merged
merged 8 commits into from
Aug 17, 2023

Conversation

marek-mihok
Copy link
Contributor

@marek-mihok marek-mihok commented Jul 19, 2023

The PR fulfills these requirements: (check all the apply)

  • It's submitted to the main branch.
  • When resolving a specific issue, it's referenced in the PR's title (e.g. feat: Add a button #xxx, where "xxx" is the issue number).
  • When resolving a specific issue, the PR description includes Closes #xxx, where "xxx" is the issue number.
  • If changes were made to ui folder, unit tests (make test) still pass.
  • New/updated tests are included

This PR prevents the endless loop by triggering the select event only if the selection was done by mouse/keyboard (or to be exact by not triggering the select event if the value is passed to the table programatically).

Closes #2069

@marek-mihok marek-mihok marked this pull request as draft July 19, 2023 07:42
@marek-mihok marek-mihok marked this pull request as ready for review July 19, 2023 11:56
@mturoci
Copy link
Collaborator

mturoci commented Jul 19, 2023

Thanks @marek-mihok. Do we have any alternative solutions? Also please add accompanying unit tests.

@marek-mihok
Copy link
Contributor Author

marek-mihok commented Aug 16, 2023

Do we have any alternative solutions?

After exhausting attempts I was not able to find any reasonable & working solution.

  • I was trying to set default selected values while creating new Selection object instead of the useEffect but without the result since FluentUI does not support other way of making selection other than using functions setKeySelected, setIndexSelected or setAllSelected.
  • The possible solution is also to emit the select event only on mouse click, but this includes implementing the custom behavior for both checkbox and row mouse clicks.

Do you have any ideas @mturoci ?

Also please add accompanying unit tests.

Done ✅

@mturoci
Copy link
Collaborator

mturoci commented Aug 16, 2023

I tried running the unit tests, but one did not pass.

image

Based on a quick glance, the assertion seems wrong so I fixed it, but please have a look at whether it indeed makes sense since you spent more than 2 minutes on this task.

Also, I introduced a different solution for the original problem, let me if it looks good to you.

@marek-mihok
Copy link
Contributor Author

Thanks @mturoci! I went through your solution and it is looking good. Also I tested manually multiple scenarios and all is working as expected.

@mturoci mturoci merged commit 95b514c into main Aug 17, 2023
2 checks passed
@mturoci mturoci deleted the feat/issue-2069 branch August 17, 2023 08:30
marek-mihok added a commit that referenced this pull request Jan 15, 2024
… (#2082)

Co-authored-by: Martin Turoci <martin.turoci@h2o.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Passing value to table with 'select' event leads to trigger-loop
2 participants